using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Media;

namespace SoulDoorEngineSmart.Components.Audio
{
    internal class SongPlayer : SoulDoorEngine.Framework.Components.Component
    {
        private Dictionary<string, Song> List = new Dictionary<string, Song>();
        private List<string> PlayingList = new List<string>();

        internal SongPlayer()
        {
        }

        internal void Add(string name)
        {
            if (!this.List.ContainsKey(name))
            {
                Song s = AudioPlayer.MyGame.Content.Load<Song>(name);
                List.Add(name, s);
            }
            else
            {
                return;
            }
        }

        internal void Play(string name)
        {
            if (PlayingList.Contains(name))
            {
                return;
            }
            if (this.List.ContainsKey(name))
            {
                MediaPlayer.Volume = 1.0f;
                MediaPlayer.Play(List[name]);
                PlayingList.Add(name);
            }
        }

        internal void Stop()
        {
            MediaPlayer.Stop();
            this.PlayingList = null;
        }
    }
}
